﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Maticsoft.DBUtility;
namespace WebManager.Function.PortalList
{
    public partial class List : System.Web.UI.Page
    {

        private LYQ.BLL.PortalList bll = new LYQ.BLL.PortalList();
        private string oid = HttpContext.Current.Request.QueryString["oid"];
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }


        private void BindData()
        {
            GridView1.DataSource = bll.GetList(" 1=1 order by PortalID asc").Tables[0];
            GridView1.DataBind();
        }
        protected void New_Click(object sender, EventArgs e)
        {
          
            string url = URLUtility.UrlBase + "/WebManager/Function/PortalList/New.aspx?oid="+oid;
            Page.Response.Redirect(url);
        }

        protected void Edit_Click(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.Form["selectCB"] == null) return;
            string[] sel = Request.Form["selectCB"].Split(',');
            if (sel.Length > 1)
            { 
                Label label = Page.Master.FindControl("lblTitle") as Label;
                label.Text = "<b>每次只能选择一项</b>";
            }
            string url = URLUtility.UrlBase + "/WebManager/Function/PortalList/Edit.aspx?EditID=" + sel[0]+"&OID="+oid;
            Page.Response.Redirect(url);
        }

        protected void Delete_Click(object sender, EventArgs e)
        {

            if (HttpContext.Current.Request.Form["selectCB"] == null) return;
            string[] sel = Request.Form["selectCB"].Split(',');
            if (sel.Length > 1)
            {
                Label label = Page.Master.FindControl("lblTitle") as Label;
                label.Text = "<b>每次只能选择一项</b>";
            }
            LYQ.BLL.PortalList bll = new LYQ.BLL.PortalList();
            bll.Delete(Convert.ToInt32(sel[0]));
            string url = URLUtility.UrlBase + "/WebManager/Function/PortalList/List.aspx?OID="+oid;
            Page.Response.Redirect(url);
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindData();
        }

      
    }
}
